import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'

// https://vite.dev/config/
export default defineConfig(({}) => {
  // API代理地址
  const API_PROXY_TARGET = 'http://123.57.91.123:12322'
  // const API_PROXY_TARGET = "http://localhost:12322";
  // http://127.0.0.1:4523/m1/7045499-6765535-default

  return {
    plugins: [
      vue(),
      vueDevTools({
        launchEditor: 'trae',
      }),
    ],
    server: {
      host: '0.0.0.0',
      port: 3000,
      allowedHosts: [
        '.f.luowb.cn', // 用于内网穿透服务器
      ],
      proxy: {
        // 将/app请求转发到后端服务器
        '/app': {
          target: API_PROXY_TARGET,
          changeOrigin: true,
          rewrite: path => path.replace(/^\/app/, ''),
        },
      },
    },
  }
})
